﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Data;
using System.Data.SqlClient;
using MDL;

namespace DAL
{
    /// <summary>
    /// 打印小票类
    /// </summary>
    public class DAL_DaYinXP
    {
        /// <summary>
        /// 打印消费信息
        /// </summary>
        /// <param name="CBID">根据账单编号</param>
        /// <returns>消费信息</returns>
        public static List<DaYinXP> JZInfo(string CBID)
        {
            string sql = @"select CDPrice,CDAmount,CDType,p.ProductName,s.CBStartDate,
                        s.CBEndDate from ConsumerDetail c inner join Products p on 
                        c.ProdcutID=p.ProductID inner join ConsumerBill s on 
                        s.CBID = c.CBID where c.CBID = @CBID and CDType = 0";
            SqlParameter[] sprs = { new SqlParameter("@CBID", CBID) };
            List<DaYinXP> list = new List<DaYinXP>();
            using (SqlDataReader dr = DBHelper.白道(sql, sprs, CommandType.Text))
            {
                while (dr.Read())
                {
                    DaYinXP d = new DaYinXP();
                    d.CDPrice = Convert.ToInt32(dr[0]);
                    d.CDNum = Convert.ToInt32(dr[1]);
                    d.CDType = Convert.ToInt32(dr[2]);
                    d.ProductName = dr[3].ToString();
                    d.CBStartDate = Convert.ToDateTime(dr[4]);
                    d.CBEndDate = Convert.ToDateTime(dr[5]);
                    list.Add(d);
                }
            }
            return list;
        }
    }
}
